;; -------- init & startup --------
(setq inhibit-startup-message t)
(setq initial-scratch-message
      ";; Hello 元辰,\n;; Enjoy counting the parentheses!\n\n")
(setq inhibit-splash-screen t
      inhibit-startup-screen t
      inhibit-startup-echo-area-message t)

;; -------- disable bell sound --------
(setq ring-bell-function 'ignore)

;; -------- no file.bk~ --------
(setq make-backup-files nil)

;; -------- coding-system --------

;; (prefer-coding-system 'utf-8)
;; (set-default-coding-systems 'utf-8)

;; ;; via: emacs-china.org/t/topic/14231/7 @dingyi342
;; ;; set coding config, last is highest priority.
;; ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Recognize-Coding.html#Recognize-Coding
;; (prefer-coding-system 'cp950)
;; (prefer-coding-system 'gb2312)
;; (prefer-coding-system 'cp936)
;; (prefer-coding-system 'gb18030)
;; (prefer-coding-system 'utf-16)
;; (prefer-coding-system 'utf-8-dos)
;; ;; (prefer-coding-system 'utf-8-unix)
;; (prefer-coding-system 'utf-8)

;; ;; via: emacs-china.org/t/win-modeline/13214/11 @zhscn
;; (when (eq system-type 'windows-nt)
;;   ;; (setq abbreviated-home-dir "\\`'")
;;   (setq locale-coding-system 'gb18030)
;;   (setq w32-unicode-filenames 'nil)
;;   (setq file-name-coding-system 'gb18030))

;; -------- disable frame-title and bars --------
;; (set-frame-parameter (car (frame-list)) 'undecorated t)
(setq default-frame-alist '((undecorated . t)))
(add-to-list 'default-frame-alist '(drag-internal-border . 1))
(add-to-list 'default-frame-alist '(internal-border-width . 1))
(when (fboundp 'menu-bar-mode)
  (menu-bar-mode -1))
(when (fboundp 'tool-bar-mode)
  (tool-bar-mode -1))
(when (fboundp 'scroll-bar-mode)
  (scroll-bar-mode -1))
(when (fboundp 'horizontal-scroll-bar-mode)
  (horizontal-scroll-bar-mode -1))

;; -------- cursor never blink --------
(add-hook 'after-init-hook
          (lambda ()
            (blink-cursor-mode -1)))

;; -------- highlight current line --------
(global-hl-line-mode 1)

;; -------- sentence end and Not with double space --------
(setq sentence-end "\\([。！？]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
(setq sentence-end-double-space nil)

;; -------- Tab and Space --------
;; Permanently indent with spaces, never with TABs
(setq-default c-basic-offset     4
              default-tab-width  4
              tab-width          4
              indent-tabs-mode nil)

;; -------- kill line including '\n' --------
;; (setq kill-whole-line t)

;; -------- whether add newline at bottom --------
;; (setq-default require-final-newline nil)

;; -------- show ediff in plain & be horizontal --------
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(setq ediff-split-window-function 'split-window-horizontally)

;; -------- auto reload file --------
(add-hook 'emacs-startup-hook
          (lambda ()
            (global-auto-revert-mode 1)))

;; -------- save place in each file --------
(save-place-mode 1)

;; -------- always use `y-or-n-p' --------
(defalias 'yes-or-no-p 'y-or-n-p)
;; (fset 'yes-or-no-p 'y-or-n-p)

;; -------- disable left mouse button click paste --------
(setq mouse-yank-at-point t)
;; disable middle mouse button click
(global-unset-key (kbd "<mouse-2>"))
;; disable the right mouse button and double click to cut
(fset 'mouse-save-then-kill 'ignore)

(provide 'base)
